/**
 * @Author ZhangCuirong
 * @Date 2025/9/8 15:56
 * @description:
 */
public class Solution50 {
    public double myPow(double x, int n) {
        if (n == 0) {
            return 1.00000;
        }
        if (n == Integer.MIN_VALUE) {
            return (1 / x) * myPow(1 / x, -(n + 1));
        }
        if (n < 0) {
            return myPow(1 / x, -n);
        }
        if (n % 2 == 0) {
            double sub = myPow(x, n / 2);
            return (sub * sub);
        } else {
            return (x * myPow(x, n - 1));
        }
    }

    public static void main(String[] args) {
        Solution50 solution = new Solution50();
        System.out.println(solution.myPow(2.00000, 10));
        System.out.println(solution.myPow(2.10000, 3));
        System.out.println(solution.myPow(2.00000, -2));
    }
}
